package com.zju.cst.cloudApp.mockSys;

import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;

public class MessageClientHandler extends SimpleChannelHandler {

	private String message;
	
	public MessageClientHandler(String message) {
		this.message = message;
	}
	
	
	@Override
	public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e)
			throws Exception {
		System.out.println("======handler connected=====");
		e.getChannel().write(message);
	}

	@Override
	public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
			throws Exception {
		System.out.println(e.getMessage());
	}

	public void setMessage(String message) {
		this.message = message;
	}

}
